package net.xo68.destiny.manager.mapper;


import net.xo68.destiny.manager.entity.SystemUser;
import org.apache.ibatis.annotations.*;
import java.util.List;

/** 
 * SystemUser mybatis mapper
 * @author wuxie(16349023@qq.com)
 * @date 2020年11月07日 16:43:18
 *
 */
public interface SystemUserMapper {


	
	@Select("SELECT * FROM destiny_system_user WHERE id = #{id}")
    @Results(value = { 
    @Result(id = true, column = "id", property = "id"),
        @Result(column = "account", property = "account"),
        @Result(column = "password", property = "password"),
        @Result(column = "nice", property = "nice"),
        @Result(column = "sex", property = "sex"),
        @Result(column = "user_state", property = "userState"),
        @Result(column = "create_time", property = "createTime"),
        @Result(column = "upate_time", property = "upateTime"),
        @Result(column = "operator", property = "operator")
    })
    SystemUser find(@Param("id") Long id);

    @Select("SELECT * FROM destiny_system_user WHERE account = #{account}")
    @Results(value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "account", property = "account"),
            @Result(column = "password", property = "password"),
            @Result(column = "nice", property = "nice"),
            @Result(column = "sex", property = "sex"),
            @Result(column = "user_state", property = "userState"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "upate_time", property = "upateTime"),
            @Result(column = "operator", property = "operator")
    })
    SystemUser findByAccount(@Param("account") String account);
	
	@Select("SELECT * FROM destiny_system_user")
    @Results(value = { 
    @Result(id = true, column = "id", property = "id"),
        @Result(column = "account", property = "account"),
        @Result(column = "password", property = "password"),
        @Result(column = "nice", property = "nice"),
        @Result(column = "sex", property = "sex"),
        @Result(column = "user_state", property = "userState"),
        @Result(column = "create_time", property = "createTime"),
        @Result(column = "upate_time", property = "upateTime"),
        @Result(column = "operator", property = "operator")
    })
    List<SystemUser> list();
	
	@Insert("insert into destiny_system_user (id ,account ,password ,nice ,sex ,user_state ,create_time ,upate_time ,operator ) values (#{id} , #{account} , #{password} , #{nice} , #{sex} , #{userState} , #{createTime} , #{upateTime} , #{operator}  )")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(SystemUser systemUser);
	
	@Update({"update destiny_system_user set",
      " account=#{account}, password=#{password}, nice=#{nice}, sex=#{sex}, user_state=#{userState}, create_time=#{createTime}, upate_time=#{upateTime}, operator=#{operator} ",
      "where id = #{id}"
    })
    int update(SystemUser systemUser);

	@Delete("delete FROM destiny_system_user WHERE id = #{id}")
	int delete(@Param("id") Long id);
}